package grsu.epam.airline.action;

import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

public class LanguageAction extends DispatchAction {

	public ActionForward en(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		request.getSession().setAttribute(Globals.LOCALE_KEY, Locale.ENGLISH);
		return mapping.findForward(ForwardActionTo.SUCCESS);
		// return new ActionForward(request.getHeader("Referer"), true);
	}

	public ActionForward ru(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Locale locale = new Locale("ru");
		request.getSession().setAttribute(Globals.LOCALE_KEY, locale);
		return mapping.findForward(ForwardActionTo.SUCCESS);
	}
	// cmd: native2ascii -encoding UTF-8 ApplicationResource_ru.prop
}